Fix SymbolTable duplicate-name handling during BFBS deserialization#9012
Fix SymbolTable duplicate-name handling during BFBS deserialization#9012steadytao wants to merge 3 commits into
Conversation
SymbolTable::Add() appended objects to its ownership vector before checking for duplicate names. During binary schema deserialization this allowed duplicate enum names to leave a freed pointer behind, which was later deleted again during teardown. Check for duplicates before storing the pointer and add a regression test that verifies a malformed BFBS fixture is accepted by VerifySchemaBuffer() but rejected safely by Parser::Deserialize(). Tested with flattests.exe; all tests passed.
Delete the temporary EnumDef in Parser::StartEnum() when duplicate-name registration fails so duplicate enum/union declarations do not leak during parsing.
|
CIFuzz found a real follow-up leak in |
|
Confirming this fix addresses a broader class of bugs than just
Plus 17 additional triggering inputs that surface the same root cause as What this means for the PRYour one-line fix in Suggested addition: broader regression setIf useful, I have minimized PoC bytes for each of the 4 additional manifestations (200 B, 231 B, 389 B, 500 B). Happy to attach them as additional entries in Companion fuzz targetSeparately, I'm preparing a Thanks for the clean fix, looking forward to seeing it land. |
More than happy for either, whichever is most preferred. As Derek may take some time to review, commiting to this PR may be the best choice. I have also confirmed the behaviour you have mentioned and will retitle as fitting. |
|
@dbaileychess Just bumping this your way. |
Summary
Reject duplicate enum names during BFBS deserialisation before transferring ownership into the symbol table.
Problem
SymbolTable::Add()appended objects to its ownership vector before checking for duplicate names. During binary schema deserialisation, duplicate enum names could therefore leave a freed pointer behind in the symbol table and later trigger a double-free during teardown.Fix
VerifySchemaBuffer()accepts the schema butParser::Deserialize()rejects it safelyTesting
flattests.exeALL TESTS PASSEDFixes #9009